<?php
    $top_menu_1 = FALSE;
    $top_menu_2 = FALSE;
    $top_menu_3 = FALSE;
    $top_menu_4 = FALSE;
    $top_menu_5 = TRUE;
    $top_menu_6 = FALSE;
    $top_menu_7 = FALSE;
    include('header.php');
    include('sidebar2.php');
    $sql = "SELECT * FROM hs_contact";
    $line = $db->queryUniqueObject($sql);
?>
            <div id="main_content" class="contact_content">
                <img src="images/contact_title.jpg" alt="Contact Us" id="contact_title" />
                
                <img src="images/contact_us.jpg" alt="Contact Us" id="contact_img" />
               
                <h3 id="contact_url"><a href="index.php" title="<?php echo $line->c_company_name; ?>"><?php echo $line->c_company_name; ?></a></h3>
                <p id="contact_msg1">You can contact us via e-mail or telephone</p>
               
                <div id="contact_address">
                    <?php echo nl2br($line->c_address); ?>
                    Tel: <?php echo $line->c_tel; ?><br />
                    Fax: <?php echo $line->c_fax; ?><br />
                    Email: <a href="mailto:<?php echo $line->c_email; ?>"><?php echo $line->c_email; ?></a>
                </div>
               
                <div id="contact_time">
                    Open hours : <?php echo $line->c_openhour; ?>
                </div>
               
                <div id="contact_map">
                    Map: Click here<br />
                    <a rel="nofollow" target="_blank" href="http://maps.google.co.th/maps?q=<?php echo $line->c_latitude; ?>%2C<?php echo $line->c_longtitude; ?>&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&ie=UTF-8&sa=N&hl=th&tab=wl" title="">Google Earth Map</a><br />
                    View map in Google Map<br />
                    Latitude: <?php echo $line->c_latitude; ?>  Longtitude: <?php echo $line->c_longtitude; ?>
                </div>
               
                <div id="contact_form">
                    <h3>Contact E-Mail:</h3>
                    <form id="contact_frm">
                        <input type="hidden" name="contact_mail" value="<?php echo $line->c_email; ?>" />
                    <table id="contact_form_tb">
                        <tr>
                            <td class="td1">Subject :</td>
                            <td class="td2"><input type="text" name="subject" id="subject" /></td>
                            <td class="td3">*</td>
                        </tr>
                        <tr>
                            <td class="td1">Your Name :</td>
                            <td class="td2"><input type="text" name="name" id="name" /></td>
                            <td class="td3">*</td>
                        </tr>
                        <tr>
                            <td class="td1">Your E-Mail :</td>
                            <td class="td2"><input type="text" name="email" id="email" /></td>
                            <td class="td3">*</td>
                        </tr>
                        <tr>
                            <td class="td1">Your Phone :</td>
                            <td class="td2"><input type="text" name="phone" id="phone" /></td>
                            <td class="td3"></td>
                        </tr>
                        <tr>
                            <td class="td1 tdtxtarea">Description :</td>
                            <td class="td2">
                                <textarea name="desc" id="desc"></textarea>
                                <p>* Please enter the correct word and number</p>
                            </td>
                            <td class="td3 tdtxtarea">
                                *
                                
                                <p id="contact_bt">
                                    <img src="images/contact_send_bt.jpg" alt="Send" id="contact_send_bt" class="img_link" />
                                    <img src="images/contact_cancel_bt.jpg" alt="Cancel" id="contact_cancel_bt" class="img_link" />
                                    <div class="clear">&nbsp;</div>
                                </p>
                                <p id="contact_bt2" class="display_none">
                                    <img src="images/ajax-loader.gif" />
                                </p>
                            </td>
                        </tr>
                    </table>
                    </form>
                </div>
                
            </div>
            <div class="clear">&nbsp;</div>
<?php
    include('footer.php');
?>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script>
    $(function() {
        $("#contact_frm").validate({
            rules: {
                subject : "required",
                name : "required",
                email: {
                    required: true,
                    email: true
                },
                desc: "required"
            },
            messages: {
                subject: "Please enter subject",
                name: "Please enter your name",
                email: {
                    required: "Please enter an email address",
                    email: "Please enter a valid email address"
                },
                desc: "Please enter description"
            }
        });
        
        $('#contact_send_bt').click(function(){
            if($("#contact_frm").valid()){
                
                $("#contact_bt").css('display','none');
                $("#contact_bt2").css('display','inline');
                
                var str = $("#contact_frm").serialize();
                $.post("function/sent-contact-mail.php", str ,function(data){
                    if(trim(data)=='success'){
                        alert('<?php echo $status_msg['contact_success']; ?>');
                        $("#contact_bt").css('display','block');
                        $("#contact_bt2").css('display','none');
                        $("#contact_frm")[0].reset();
                    }else{
                        alert(data);
                        $("#contact_bt").css('display','block');
                        $("#contact_bt2").css('display','none');
                        $("#ajax_loader").css('display','none');
                    }
                });
            }
        });
    });
</script>